set more off

use "NES2000 (raw).dta"

**********Dependent Variable: Vote Choice****************
gen vote = .
replace vote = 1 if V001249 == 3
replace vote = 0 if V001249 == 1
label def vot 1 "Bush" 0 "Gore"
label values vote vot
tab vote V001249


**** political knowledge -   so that 'informed' placements can be obtained below'
	label def corre 1 "Correct" 0 "Incorrect/No Guess"
*lott 
	recode V001447 (0=.) (1=1) (5=0) (8=0) (9=.), gen(lott)
	label var lott "Trent Lott Knowledge"
	label values lott corre
*reinquist
	recode V001450 (0=.) (1=1) (5=0) (8=0) (9=.), gen(rein)
	label var rein "Reinquist Knowledge" 
	label values rein corre
*Blair
	recode V001453 (0=.) (1=1) (5=0) (8=0) (9=.), gen(blair)
	label var blair "Blair Knowledge"
	label values blair corre
*Reno
	recode V001456 (0=.) (1=1) (5=0) (8=0) (9=.), gen(reno)
	label var reno "Reno Knowledge"
	label values reno corre
*bush state: K3a
	recode V001458 (0=.) (1=0) (2=0) (3=1) (4=0) (7=0) (8=0) (9=.), gen(bush_state)
	label var bush_state "Bush State Knowledge"
	label values bush_state corre
*bush religion: K3b
	*correct = methodist*
	recode  V001460 (0=0) (1=0) (2=1) (3=0) (7=0) (8=0) (9=.), gen(bush_religion)
	label var bush_religion "Bush Religion Knowledge"
	label values bush_religion corre
*gore state k4a
	*correct = tennessee
	recode V001462 (0=.) (1=0) (2=1) (3=0) (4=0) (7=0) (8=0) (9=.), gen(gore_state)
	label var gore_state "Gore State Knowledge"
	label values gore_state corre
*gore religion: k4b
	*correct = baptist
	recode V001464 (0=0) (1=1) (2=0) (3=0) (7=0) (8=0) (9=.), gen(gore_religion)
	label var gore_religion "Gore Religion Knowledge"
	label values gore_religion corre
*cheney state
	*correct = wyoming
	recode V001466 (0=.) (1=0) (2=0) (3=0) (4=1) (7=0) (8=0) (9=.), gen(cheney_state)
	label var cheney_state "Cheney State Knowledge"
	label values cheney_state corre
*cheney religion
	*correct = methodist*
	recode V001468 (0=0) (1=0) (2=1) (3=0) (7=0) (8=0) (9=.), gen(cheney_religion)
	label var cheney_religion "Cheney Religion Knowledge"
	label values cheney_religion corre
*lieberman state
	*correct = ct
	recode V001470 (0=.) (1=1) (2=0) (3=0) (4=0) (7=0) (8=0) (9=.), gen(lieb_state)
	label var lieb_state "Liberman State Knowledge"
	label values lieb_state corre
*lieberman religion
	*correct = jewish
	recode V001472 (0=0) (1=0) (2=0) (3=1) (7=0) (8=0) (9=.), gen(lieb_religion)
	label var lieb_religion "Liberman Religion Knowledge"
	label values lieb_religion corre

*Descriptives
	foreach var in lott rein blair reno bush_state bush_religion gore_state gore_religion cheney_state cheney_religion lieb_state lieb_religion   { 
		tab `var'
		}

*Summary scale
	egen knowl = rowtotal(lott rein blair reno bush_state bush_religion gore_state gore_religion cheney_state cheney_religion lieb_religion lieb_state), missing
	label var knowl "Knowledge"
	tab knowl
	summ knowl, detail
		

**********Main Ind. Variable: Policy Attitude, Importance, Proximity****************
****Abortion****

**own attitude, candidate placements**
label def abor 1 "Always able to obtain" 4 "never permitted" 
gen abortion2000 = . 
replace abortion2000 = 1 if V000694 == 4
replace abortion2000 = 2 if V000694 == 3
replace abortion2000 = 3 if V000694 == 2
replace abortion2000 = 4 if V000694 == 1

gen goreabortion2000 = .
replace goreabortion2000 = 1 if V000696 == 4
replace goreabortion2000 = 2 if V000696 == 3
replace goreabortion2000 = 3 if V000696 == 2
replace goreabortion2000 = 4 if V000696 == 1

gen bushabortion2000 = . 
replace bushabortion2000 = 1 if V000698 == 4
replace bushabortion2000 = 2 if V000698 == 3
replace bushabortion2000 = 3 if V000698 == 2
replace bushabortion2000 = 4 if V000698 == 1

label values abortion2000 abor
label values goreabortion2000 abor
label values bushabortion2000 abor


***proximity**

*Sample mean
summarize goreabortion2000 bushabortion2000
*gore: 1.72419
*bush: 2.860031

*city block
gen abortion2000prox = abs(abortion2000 - 1.72419) - abs(abortion2000 - 2.860031)
label var abortion2000prox "Proximity: Abortion"


*informed: city block
summ goreabortion2000 bushabortion2000 if knowl >=5 & knowl <=11
*gore: 1.426056
*bush: 2.921533

gen abortion2000prox_info = abs(abortion2000 - 1.426056) - abs(abortion2000 - 2.921533)
label var abortion2000prox_info "Proximity: Abortion (Informed)"
summ abortion2000prox_info

*city block: own placement*
gen abortion2000prox_self = abs(abortion2000 - goreabortion2000) - abs(abortion2000 - bushabortion2000)
label var abortion2000prox_self "Proximity: Abortion (Self-Placement)"
summ abortion2000prox_self


*euclidean
gen abortion2000prox_euclid1 = [(abortion2000 - 1.72419)*(abortion2000 - 1.72419)] - [(abortion2000 - 2.860031)*(abortion2000 - 2.860031)]
label var abortion2000prox_euclid1 "Proximity: Abortion (Euclid; Sample)"
gen abortion2000prox_euclid2 = [(abortion2000 - 1.426056)*(abortion2000 - 1.426056)] - [(abortion2000 - 2.921533)*(abortion2000 - 2.921533)]
label var abortion2000prox_euclid2 "Proximity: Abortion (Euclid: Informed)"
gen abortion2000prox_euclid3 = [(abortion2000 - goreabortion2000)*(abortion2000 - goreabortion2000)] - [(abortion2000 - bushabortion2000) * (abortion2000 - bushabortion2000)]
label var abortion2000prox_euclid3 "Proximity: Abortion (Euclid; Own)"

summ abortion2000prox_euclid*


**attitude strength**
label def imp 1 "Not Imp at All" 3 "Somewhat Important" 5 "Extremely Important" 
rename V000695 abortion2000imp
mvdecode abortion2000imp, mv(0 = . \ 8 = . \ 9 = .) 



**standardized**
foreach var in abortion2000prox abortion2000imp abortion2000prox_info abortion2000prox_self abortion2000prox_euclid1 abortion2000prox_euclid2 abortion2000prox_euclid3 {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
	
	
label var abortion2000prox01 "Abortion:Prox"
label var abortion2000imp01 "Abortion:Imp"

****Gun Restrictions***
**own attitude, candidate placements**
tab V000731 
*conservative position is high already
rename V000731 guns2000 
label var guns2000 "Gun Control"
rename V000735 goreguns2000
rename V000739 bushguns2000
mvdecode guns2000 goreguns2000 bushguns2000, mv(0 = . \ 8 = . \ 9 = .) 

***proximity**
*sample mean: 
summarize bushguns2000 goreguns2000
*bush: 2.927711
*gore: 1.792691

*city block
gen guns2000prox = abs(guns2000 - 1.792691) - abs(guns2000 - 2.927711)
label var guns2000prox "Proximity: Gun  Control (Sample)"
summ guns2000prox

*city block: informed
summ bushguns2000 goreguns2000 if knowl >=5 & knowl <= 11
*gore: 1.735786
*bush: 3.242525 

gen guns2000prox_info = abs(guns2000 - 1.735786) - abs(guns2000 - 3.242525)
label var guns2000prox_info "Proximity: Gun Control (Informed)"


*city block: own
	gen guns2000prox_self = abs(guns2000 - goreguns2000) - abs(guns2000 - bushguns2000)
	label var guns2000prox_self "Proximity: Gun Control (Self)"


*euclidean
	gen guns2000prox_euclid1 = [(guns2000 - 1.792691)*(guns2000 - 1.792691)] - [(guns2000 - 2.927711)*(guns2000 - 2.927711)]
	label var guns2000prox_euclid1 "Prox: Gun Control (Euclid; Sample)"
	gen guns2000prox_euclid2 = [(guns2000 - 1.735786)*(guns2000 - 1.735786)] - [(guns2000 - 3.242525)*(guns2000 - 3.242525)]
	label var guns2000prox_euclid2 "Prox: Gun Control (Euclid; Informed)"
	gen guns2000prox_euclid3 = [(guns2000 - goreguns2000)*(guns2000 - goreguns2000) ] - [(guns2000 - bushguns2000)*(guns2000 - bushguns2000)]
	label var guns2000prox_euclid3 "Prox: Gun Control (Euclid: Self)"

	summ guns2000prox_info guns2000prox_self guns2000prox_euclid1 guns2000prox_euclid2 guns2000prox_euclid3


**attitude strength**
	gen guns2000ext = . 
	replace guns2000ext = 1 if guns2000 == 3
	replace guns2000ext = 2 if guns2000 == 2
	replace guns2000ext = 2 if guns2000 == 4
	replace guns2000ext = 3 if guns2000 == 1
	replace guns2000ext = 3 if guns2000 == 5
	label var guns2000ext "Gun Control: Extremity"
	label def gun 1 "The Same" 2 "Somewhat" 3 "A Lot"
	label values guns2000ext gun

	rename V000732 guns2000imp 
	mvdecode guns2000imp, mv(0 = . \ 8 = . \ 9 = .) 


**standardized**
	foreach var in guns2000prox guns2000imp guns2000ext guns2000prox_info guns2000prox_self guns2000prox_euclid1 guns2000prox_euclid2 guns2000prox_euclid3 {
			qui sum `var'
			gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
		}
		
label var guns2000prox01 "Guns:Prox"
label var guns2000imp01 "Guns:Imp"		


***Environment vs. Burdening Businesses****
**own attitude, candidate placements**
	rename V000776 regulation2000 
	rename V000783 goreregulation2000
	rename V000790 bushregulation2000
	mvdecode regulation2000 goreregulation2000 bushregulation2000, mv(0 = . \ 8 = . \ 9 = .)


**proximity**

*sample mean
	summarize goreregulation2000 bushregulation2000
		*gore: 2.090976
		*bush: 3.338426


*city block: sample
	gen regulation2000prox = abs(regulation2000 - 2.090976) - abs(regulation2000 - 3.338426)
	label var regulation2000prox "Prox: Enviro Regulation (Sample)"
	
*city block: informed
	summ goreregulation2000 bushregulation2000 if knowl >=5 & knowl <= 11
	*bush: 3.573477
	*gore: 1.87372
	gen regulation2000prox_info = abs(regulation2000 - 1.87372) - abs(regulation2000 - 3.573477)
	label var regulation2000prox_info "Prox: Enviro Regulation (Informed)"	
	
*city block: self
	gen regulation2000prox_self = abs(regulation2000 - goreregulation2000) - abs(regulation2000 - bushregulation2000)
	label var regulation2000prox_self "Prox: Enviro Regulation (Self)"	
	

*euclidean
	gen regulation2000prox_euclid1 = [(regulation2000 - 2.090976)*(regulation2000 - 2.090976)] - [(regulation2000 -  3.338426)*(regulation2000 -  3.338426)]
	label var regulation2000prox_euclid1 "Prox: Enviro Regulation (Euclid; Sample)"
	
	gen regulation2000prox_euclid2 = [(regulation2000 - 1.87372)*(regulation2000 - 1.87372)] - [(regulation2000 -  3.573477)*(regulation2000 -  3.573477)]
	label var regulation2000prox_euclid2 "Prox: Enviro Regulation  (Euclid; Informed)"
	
	gen regulation2000prox_euclid3 = [(regulation2000 - goreregulation2000)*(regulation2000 - goreregulation2000) ] - [(regulation2000 - bushregulation2000)*(regulation2000 - bushregulation2000)]
	label var regulation2000prox_euclid3 "Prox: Enviro Regulation  (Euclid: Self)"

	summ regulation2000prox regulation2000prox_info regulation2000prox_self regulation2000prox_euclid1 regulation2000prox_euclid2 regulation2000prox_euclid3 

**attitude strength**
gen regulation2000ext = .
replace regulation2000ext =  1 if regulation2000 == 3
replace regulation2000ext =  2 if regulation2000 == 2
replace regulation2000ext =  2 if regulation2000 == 4
replace regulation2000ext =  3 if regulation2000 == 1
replace regulation2000ext =  3 if regulation2000 == 5
label var regulation2000ext "Enviro Regulations: Extremity"

rename V000777 regulation2000imp
mvdecode regulation2000imp,  mv(0 = . \ 8 = . \ 9 = .)

**standardized**

foreach var in regulation2000prox regulation2000imp regulation2000ext  regulation2000prox_self regulation2000prox_euclid1 regulation2000prox_euclid2 regulation2000prox_euclid3 regulation2000prox_info {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}
	
	
label var regulation2000prox01 "Env.Regulation:Prox"
label var regulation2000imp01 "Env.Regulation:Imp"

**********Control Variables****************
**PID
rename V000523 pid
mvdecode pid, mv(7 = . \ 8 = . \ 9 = .)
label var pid "PID"
summarize pid
gen pid01 = (pid - `r(min)') / (`r(max)'-`r(min)')
label var pid01 "PID"


**Ideology

gen ideology = V000446
mvdecode ideology, mv(0 = . \ 8 = . \ 9 = .) 
label var ideology "Ideology"
summarize ideology 
gen ideology01 = (ideology - `r(min)') / (`r(max)'-`r(min)')
label var ideology01 "Ideology"

gen ideology2 = V000446
recode ideology2 (0 = 8) (9 = 8)
label var ideology2 "Ideology (Full)"
label def ideo1 8 "Haven't Thought Much/DK/NA" 1 "Ext. Liberal"  7 "Ext. Conservative" 4 "Moderate"
label values ideology2 ideo1

recode V000446 (1=1) (2=1) (3=1) (4=2) (5=3) (6=3) (7=3) ///
	(8=4) (9=4) (0=4), gen(ideol)
	
	label var ideol "Ideology"
	label def id 1 "Liberal" 2 "Moderate" 3 "Conservative" 4 "NA/DK/Refuse"
	label values ideol id
	


**Age
rename V000908 age
mvdecode age, mv(00 = .)
summarize age
gen age01 = (age - `r(min)') / (`r(max)'-`r(min)')
label var age01 "Age"

**Gender
gen gender = .
replace gender = 1 if V001029 == 2
replace gender = 0 if V001029 == 1
label var gender "Gender" 
label def gen 1 "Female" 0 "Male"
label values gender gen
tab gender V001029

**Race

gen race = . 
replace race = 1 if V001006a >= 10 & V001006a <= 40
replace race = 1 if V001006a >=60 & V001006a <= 90
replace race = 0 if V001006a == 50
label var race "Race" 
label def ra 1 "Non-White" 0 "White"
label values race ra

gen hispanic = . 
replace hispanic = 1 if V001012 == 1
replace hispanic = 0 if V001012 == 5
label var hispanic "Hispanic"
label def his 1 "Hispanic" 0 "Non-Hispanic"
label values hispanic his


**Education
gen educ = . 
replace educ = 1 if V000913 == 1
replace educ = 1 if V000913 == 2
replace educ = 2 if V000913 == 3
replace educ = 3 if V000913 == 4
replace educ = 3 if V000913 == 5
replace educ = 4 if V000913 == 6
replace educ = 4 if V000913 == 7
label var educ "Education" 
label def ed 1 "< HS" 2 "HS" 3 "Some College" 4 "College+" 
label values educ ed


summarize educ
gen educ01 = (educ - `r(min)') / (`r(max)'-`r(min)')
label var educ01 "Education"


**Income
rename V000994 famincome
rename V000997 income
mvdecode famincome income, mv(0 = . \ 98 = . \ 99 = .)

foreach var in income famincome {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')

	}
	
label var famincome "Family Income"
label var income "Own Income"
label var income01 "Own Income"
label var famincome01 "Family Income"

egen income_pct = cut(income), group(10) label
gen income_miss = . 
replace income_miss = 1 if income == .
gen income_pct1 = income_pct 
replace income_pct1 = 10 if income_miss == 1 & income_pct1 == . 
label def inc_mis1 10 "Missing Income"
label values income_pct1 inc_mis1


egen famincome_pct = cut(famincome), group(10) label
gen famincome_miss = .
replace famincome_miss = 1 if famincome == . 
replace famincome_miss = 0 if famincome !=.

gen famincome_pct1 = famincome_pct 
replace famincome_pct1 = 11 if famincome_miss == 1 & famincome_pct1 == .
label def inc_mis2 11 "Missing Income" 
label values famincome_pct1 inc_mis2


**Retrospective Evals**
gen econ2000 = .
replace econ2000 = 1 if V000491 == 5
replace econ2000 = 2 if V000491 == 4
replace econ2000 = 3 if V000491 == 3
replace econ2000 = 4 if V000491 == 2
replace econ2000 = 5 if V000491 == 1

summarize econ2000
gen econ01 = (econ2000 - `r(min)') / (`r(max)'-`r(min)')
label var econ01 "Economic Eval"


**Candidate Traits
label def trai 1 "Not Well at All" 4 "Extremely Well"
gen gore2000moral = . 
replace gore2000moral = 1 if V000524 == 4
replace gore2000moral = 2 if V000524 == 3
replace gore2000moral = 3 if V000524 == 2
replace gore2000moral = 4 if V000524 == 1
gen gore2000knowl = .
replace gore2000knowl = 1 if V000526 == 4
replace gore2000knowl = 2 if V000526 == 3
replace gore2000knowl = 3 if V000526 == 2
replace gore2000knowl = 4 if V000526 == 1
gen gore2000leader = . 
replace gore2000leader = 1 if V000527 == 4
replace gore2000leader = 2 if V000527 == 3
replace gore2000leader = 3 if V000527 == 2
replace gore2000leader = 4 if V000527 == 1
label values gore2000leader trai
label values gore2000knowl trai
label values gore2000moral trai


gen bush2000moral = .
replace bush2000moral = 1 if V000531 == 4
replace bush2000moral = 2 if V000531 == 3
replace bush2000moral = 3 if V000531 == 2
replace bush2000moral = 4 if V000531 == 1
gen bush2000knowl = .
replace bush2000knowl = 1 if V000533 == 4
replace bush2000knowl = 2 if V000533 == 3
replace bush2000knowl = 3 if V000533 == 2
replace bush2000knowl = 4 if V000533 == 1
gen bush2000leader = . 
replace bush2000leader = 1  if V000534 == 4
replace bush2000leader = 2  if V000534 == 3
replace bush2000leader = 3  if V000534 == 2
replace bush2000leader = 4  if V000534 == 1

label values bush2000leader trai
label values bush2000knowl trai
label values bush2000moral trai


*Comparative Traits*
gen moral2000 = bush2000moral - gore2000moral
gen knowl2000 = bush2000knowl - gore2000knowl
gen leader2000 = bush2000leader - gore2000leader



foreach var in  moral2000 knowl2000 leader2000 {
		qui sum `var'
		gen `var'01 = (`var' - `r(min)') / (`r(max)'-`r(min)')
	}

